import React from 'react'
import store from '../../store/store'
import FilePage from "../FilePage/FilePage";
import DirectoryPage from "../DirectoryPage/DirectoryPage";
import "./ModulePage.css"
import API from "../../api/api";
import {getModule} from "../../util/login";
export default class ModulePage extends React.Component{
    constructor(props) {
        super(props);
        //bind(this)，防止babel解析时走丢函数的this指向
        // this.storeFresh = this.storeFresh.bind(this)
        // store.subscribe(this.storeFresh)
        this.getData(props)
        const modules =JSON.parse(sessionStorage.getItem("breadCrumbList"))
        let item = {title:modules[0].NAME,type:"folder-d",id:this.data.id};
        API.userAccessLog(item);
    }

    data = {
        id:null,
        type:"module",
        moduleType:null
    }

    UNSAFE_componentWillReceiveProps(nextProps, nextContext) {
        this.getData(nextProps)
        const modules =JSON.parse(sessionStorage.getItem("breadCrumbList"))
        let item = {title:modules[0].NAME,type:"folder-d",id:this.data.id};
        API.userAccessLog(item);
    }

    getData=(props)=>{
        let tmpArr = props.match.params.id.split("&")
        this.data.moduleType = tmpArr[0]
        this.data.id = tmpArr[1]
    }

    render() {
        return (
            <div>
                <DirectoryPage {...this.data}></DirectoryPage>
            </div>
        )
    }
}
